package com.wzj.uarmor.utils;

import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liulei
 * 单行处理 ，后期扩展
 */
public class TextUtil {
    public static List<Map> readText2Map(BufferedReader bufferedReader) {

        List<Map> resultList = new ArrayList<>();
        List<String> headerList = null;
        try {
            // 读取行
//            int a = bufferedReader.readLine().length();
            for (int i = 0; i <= bufferedReader.read(); i++) {
                String line = bufferedReader.readLine().trim();
                //拆分
                String[] s =  line.split(":");
                Map<String, String> m = new HashMap<>();
                m.put(s[0],s[1].trim());
                resultList.add(m);

            }

//            while ( bufferedReader.readLine() != null ){
//                String line = bufferedReader.readLine();
//                line = line.trim();
//                //拆分
//                String[] s =  line.split(":");
//                Map<String, String> m = new HashMap<>();
//                m.put(s[0],s[1].trim());
//                resultList.add(m);
//            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultList;
    }
}
